// 泛型： 可以使用泛型来创建可重用的组件，一个组件可以支持多种类型的数据

function add<T>(a: T): T {
  return a;
}

add<number>(123);
add<string>("123");

interface Person<T, U> {
  name: string;
  age: T;
  code: U;
}

const p1: Person<number, number> = {
  name: "张三",
  age: 18,
  code: 123235431231231231,
};

const p2: Person<string, number> = {
  name: "张三",
  age: "18",
  code: 1231241231231,
};

class Animal<T, U> {
  name: string;
  age: T;
  sex: U;
  constructor(name: string, age: T, sex: U) {
    this.name = name;
    this.age = age;
    this.sex = sex;
  }
}

new Animal<string, string>("猫咪", "3", "母");
